package com.example.drugaiservice.controller;

import com.example.drugaiservice.common.result.Result;
import com.example.drugaiservice.pojo.dto.NameDTO;
import com.example.drugaiservice.pojo.entity.Message;
import org.springframework.ai.chat.ChatResponse;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.ollama.OllamaChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import java.util.Map;
@CrossOrigin
@RestController
public class ChatController {

    private final OllamaChatClient chatClient;

    @Autowired
    public ChatController(OllamaChatClient chatClient) {
        this.chatClient = chatClient;
    }
    //这个是症状查询的接口，传入一个String类型字符串并返回结果
    @PostMapping("/ai/ask")
    public Result<Message> generate(@RequestBody Message msg) {
        String msgs=msg+"请你给我一些建议";
        return Result.success(Message.builder().message(chatClient.call(msgs)).build());
    }


}